data = data3d('../data/head.npz', 'short')

# transfer function parameters
tf = data1d_rgba('bone.png', 'uchar')
tf_opacity = float_param(0.1, 0, 1, 'O')
tf_pos = float_param(-200, -400, 400, 'P')
tf_width = float_param(200, 100, 1000, 'W')

# cut plane position
cut = float_param(-1.8, -1.8, 1.8, 'C')

# query CT
density = cubic_query_3d_cut(data, X, D, cut) * 32768

# apply transfer function
tf_query = (density - tf_pos) / tf_width
if tf_query < 0: return 0
rgba = linear_query_1d_rgba(tf, tf_query*2 - 1)

return float4(rgba.x, rgba.y, rgba.z, rgba.w * tf_opacity)
